﻿using System;
using System.Windows;
using Csla.Xaml;
using Accounting.Library;

namespace csla4Skeleton.UI.SL.NghiepVu.TaiSanCoDinh.TSCD_KhauHao
{
    public partial class TSCD_KhauHao_ListViewModel : ViewModel<TSCD_KhauHaoList>
    {

        public TSCD_KhauHao_ListViewModel(string mode)
        {
            BeginRefresh("GetTSCD_KhauHaoList", mode);

        }

        public void GetTSCD_KhauHao_ListViewModel(string mode)
        {
            BeginRefresh("GetTSCD_KhauHaoList", mode);
        }

        public static readonly DependencyProperty SelectedItemProperty =
          DependencyProperty.Register("SelectedItem", typeof(TSCD_KhauHaoInfo), typeof(TSCD_KhauHao_ListViewModel), null);
        public TSCD_KhauHaoInfo SelectedItem
        {
            get { return (TSCD_KhauHaoInfo)GetValue(SelectedItemProperty); }
            set { SetValue(SelectedItemProperty, value); }
        }

        public void DeleteTSCD_KhauHao(object sender, ExecuteEventArgs e)
        {
            if (e.MethodParameter != null)
            {
                //cast OrderID parameter
                int Khoa = Int16.Parse(e.MethodParameter.ToString());
                this.IsBusy = true;
                Accounting.Library.TSCD_KhauHao.DeleteTSCD_KhauHao(Khoa, (o, ex) =>
                {
                    BeginRefresh("GetTSCD_KhauHaoList",BusinessConfiguration.Configuration.GridViewFetchMode);
                });
                this.IsBusy = false;
            }
        }	
    }
}
